package com.gexin.model.activity;

import com.gexin.model.activity.base.BaseUserActivity;

import java.util.List;

public class UserActivity
        extends BaseUserActivity<UserActivity>
{
    public static final UserActivity dao = new UserActivity();

    public List<UserActivity> findListByCoupon(String id)
    {
        return find("Select * from t_user_activity where activity_id=?", new Object[] { id });
    }

    public List<UserActivity> findUserIdAndActivityId(Integer userId, String activityId)
    {
        return find("select * from t_user_activity where user_id=? and activity_id=? and (status=0 or status=99)", new Object[] { userId, activityId });
    }

    public List<UserActivity> findByUserId(Integer userId)
    {
        return find("select ua.*,ac.product_id,ac.product_sku_id from t_user_activity ua LEFT JOIN t_activity ac on ac.id= ua.activity_id where ua.user_id=? and (ua.status=0 or ua.status=99)", new Object[] { userId });
    }

    public UserActivity findFirstByUserIdAndActivityId(Integer authUserId, String activityId)
    {
        return (UserActivity)findFirst("select * from t_user_activity where user_id=? and activity_id=? and status=0", new Object[] { authUserId, activityId });
    }
}
